package com.woniu.mealsService.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.woniu.mealsService.model.FoodType;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 菜品类型表 Mapper 接口
 * </p>
 *
 * @author jiang
 * @since 2024年12月09日
 */
@Mapper
public interface FoodTypeMapper extends BaseMapper<FoodType> {
    @Select("select * from food_type where store_id = #{storeId}")
    List<FoodType> searchFoodTypeList(@Param("storeId") String storeId);
    @Delete("delete from food_type where not exists (select 1 from store_product where food_type_id=#{foodTypeId}) and food_type_id = #{foodTypeId}")
    Integer deleteFoodType(@Param("foodTypeId") Long foodTypeId);

    @Select("select * from food_type where food_type_id = #{foodTypeId}")
    FoodType searchFoodTypeById(@Param("foodTypeId") Long foodTypeId);
}
